package com.free.semantic.core.businessfunction.impl;

import com.free.semantic.common.Ls;
import com.free.semantic.common.RangeObj;
import com.free.semantic.core.Context;
import com.free.semantic.core.businessfunction.BasicFunction;
import com.free.semantic.core.businessfunction.ObjectConst;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class HabitToHabitName implements BasicFunction {


    Map<String, String> testData = new HashMap<>();


    @PostConstruct
    public void init() {
        testData.put("1", "健身");
        testData.put("2", "喝水");
    }

    @Override
    public List<RangeObj> require() {
        return Ls.of(RangeObj.one(ObjectConst.HABIT));
    }

    @Override
    public RangeObj provider() {
        return RangeObj.one(ObjectConst.HABIT_NAME);
    }

    @Override
    public void calculate(Context context) {
        String id = (String) context.getListValue(ObjectConst.HABIT).get(0);
        context.setValue(ObjectConst.HABIT_NAME, testData.get(id));
    }
}
